Page({
  data: {
    businessId: '',
    formData: {
      name: '',
      phone: '',
      company: '',
      business: '',
      description: ''
    }
  },

  onLoad(options) {
    const { id } = options
    this.setData({ businessId: id })
  },

  onSubmit(e) {
    const formData = e.detail.value
    
    // 表单验证
    if (!formData.name.trim()) {
      wx.showToast({
        title: '请输入申请人姓名',
        icon: 'none'
      })
      return
    }
    
    if (!formData.phone.trim()) {
      wx.showToast({
        title: '请输入联系电话',
        icon: 'none'
      })
      return
    }
    
    if (!formData.company.trim()) {
      wx.showToast({
        title: '请输入公司名称',
        icon: 'none'
      })
      return
    }
    
    if (!formData.business.trim()) {
      wx.showToast({
        title: '请输入经营业态',
        icon: 'none'
      })
      return
    }

    // 提交申请
    wx.showLoading({
      title: '提交中...'
    })

    // TODO: 调用提交申请API
    setTimeout(() => {
      wx.hideLoading()
      wx.showToast({
        title: '申请已提交',
        icon: 'success',
        duration: 2000
      })
      
      // 延迟返回上一页
      setTimeout(() => {
        wx.navigateBack()
      }, 2000)
    }, 1500)
  }
}) 